package com.itheima.mapper;

import com.itheima.pojo.Emp;
import com.itheima.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {

//    @Select( "select count(*) from emp left join dept d on d.id = emp.dept_id")
//    Long selectTotal();
//    @Select("select e.*,d.name from emp e " +
//            "left join dept d on d.id = e.dept_id ")
//    List<Emp> selectPage();

//List<Emp> selectPage();

    List<Emp> selectPage(EmpQueryParam empQueryParam);
    @Options (useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into emp(username,password,name,gender,phone,job,salary,image,entry_date,dept_id,create_time,update_time) "
            +"values(#{username},#{password},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void add(Emp emp);
    @Select("select * from emp")
    List<Emp> findAll();


    void deleteByIds(List<Integer> ids);

    @Select("select * from emp where id=#{id}")
    Emp getById(Integer id);

    void update(Emp emp);

    @Select("select * from emp where username=#{username} and password=#{password}")
    Emp getUsernameandPassword(Emp emp);
    @Select("select count(*) from emp where emp.dept_id=#{deptid}")
    Long countById(Integer id);

    List<Map<String, Object>> countEmpJobData();
    @MapKey("name")
    List<Map> countByGender();




}
